package com.fm.financemanage.utils;

import com.fm.financemanage.function.PerformanceAnalysisFunction;
import lombok.extern.slf4j.Slf4j;


@Slf4j
public class PerformanceAnalysisUtils {


    public static <T> T invoke(String methodName, PerformanceAnalysisFunction<T> function) {
        log.info("方法开始执行:{}", methodName);
        long start = System.currentTimeMillis();
        T apply = function.apply();
        long end = System.currentTimeMillis();
        log.info("方法执行结束:{},共耗时:{}s", methodName, (end - start) * 1.0 / 1000);
        return apply;
    }
}
